Skip to content

[WEB-8784] Enforce max image width via Fastly IO params in img shortcode#35926

Open
nsollecito wants to merge 3 commits intomasterfrom
nsollecito/img-max-width
Open

[WEB-8784] Enforce max image width via Fastly IO params in img shortcode#35926
nsollecito wants to merge 3 commits intomasterfrom
nsollecito/img-max-width

Conversation

@nsollecito
Copy link
Copy Markdown
Collaborator

@nsollecito nsollecito commented Apr 10, 2026

What does this PR do? What is the motivation?

Fixes WEB-8784: https://datadoghq.atlassian.net/browse/WEB-8784

The img.html shortcode computed a max display width ($img_w: 850px standard, 1170px wide) but never applied it to the Fastly IO image URL. Every image was served at full resolution via ?auto=format only, regardless of actual display size.

This change appends &w=$img_w to the Fastly IO URL in all three $e assignment branches, capping image downloads to the content column constraints. Also renames $imgix_w$img_w for CDN-agnostic naming.

Noticeable difference in larger-asset sizes. Validate downloaded file sizes on the /logs page compared with live: https://docs-staging.datadoghq.com/nsollecito/img-max-width/logs/

Merge instructions

Merge readiness:

  • Ready for merge

Additional notes

Content column is col-lg-7 of a 1170px container (~682px rendered width). The 850px cap for standard images provides ~1.25x retina headroom; 1170px for wide images matches the full container width.

@nsollecito nsollecito requested a review from a team as a code owner April 10, 2026 20:33
@github-actions github-actions bot added the Architecture Everything related to the Doc backend label Apr 10, 2026
…tcode

- Add &fit=max to Fastly IO URL to prevent upscaling images smaller than the width cap
- Add $e2x with &dpr=2 for retina displays, applied to all srcset attributes as "1x, 2x" descriptors
- Consolidate triple $e definition into a single assignment; remove redundant inner re-assignments in wide and standard branches

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Strip ?ch=Width,DPR and ?ch=Width,Save-Data from all Fastly IO URLs — these
were Imgix-specific client hint params not used by Fastly IO. Also rename
the imgix config key to img for CDN-agnostic naming.

Files updated: img.html shortcode, img.html partial, left-nav.html,
platforms.html, vimeo.html, tile-nav.html, config/_default/params.yaml

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Architecture Everything related to the Doc backend chore

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant